/*
 * Copyright (c) 2010 Philip Foulkes <philip.foulkes@gmail.com>
 *
 * This file is free software and is made available under the 
 * terms of the GNU General Public License, version 2, or at your
 * option, any later version
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#include <linux/random.h>

#include "mrp_timer.h"

u32 mrp_timer_get_random_leave_all_time (void)
{
	u32 r;
	get_random_bytes (&r, sizeof(r));
	r %= (MRP_TIMER_VALUE_LEAVE_ALL_TIME_MAX - MRP_TIMER_VALUE_LEAVE_ALL_TIME_MIN);
	return MRP_TIMER_VALUE_LEAVE_ALL_TIME_MIN + r;
}

u32 mrp_timer_get_random_join_time (void)
{
	u32 r;
	get_random_bytes (&r, sizeof(r));
	r %= (MRP_TIMER_VALUE_JOIN_TIME_MAX - MRP_TIMER_VALUE_JOIN_TIME_MIN);
	return MRP_TIMER_VALUE_JOIN_TIME_MIN + r;
}
